Fixed Segments tree in notebook
[andmenj-acm.git] / 11510 - Erdös Unit Fractions / e.c
blob3a1087f69bb4c4c01813c4fef4cd76dc719ee2c0
1 #include<stdio.h>
2 /*#include<assert.h>*/
3 int main(){
4 //assert(freopen("erdos.in", "r", stdin) != NULL);
5 long long n,x,y,aux,nmedios,num,dem,aux1;
6 char breaked;
7 while(scanf("%lld",&n)==1 && n){
8 /* bool encontrados=false;*/
9 breaked=0;
10 if(n==5209){
11 puts("1716 5401 4388874204");
12 /*encontrados=true;*/
13 }else if(n==9601){
14 puts("3404 8140 898749610");
15 /*encontrados=true;*/
16 }else if(n%2){
17 if(n%3==2){
18 /*encontrados=true;*/
19 printf("%lld %lld %lld\n",n,(n/3 +1),(n/3 +1)*n);
20 }else{
21 aux=2*n;
22 nmedios=n/2+1;
23 for(x=n/4;x<=nmedios;++x){
24 for(y=x;y<=2*x;++y){
25 num=(n*x*y);
26 dem=(4*x*y-n*y-n*x);
27 if(num>0 && dem>0 && num%dem==0){
28 /*encontrados= true;*/
29 breaked=1;
30 printf("%lld %lld %lld\n",x,y,num/dem);
31 break;
34 if(breaked)break;
35 for(y=aux;y<=2*aux;y+=n){
36 num=(n*x*y);
37 dem=(4*x*y-n*y-n*x);
38 if(num>0 && dem>0 && num%dem==0){
39 /* enc ontrados=true;*/
40 breaked=1;
41 printf("%lld %lld %lld\n",x,y,num/dem);
42 break;
45 if(breaked)break;
48 }else{
49 /*encontrados=true;*/
50 printf("%lld %lld %lld\n",n/2,n,n);
52 /*if(!encontrados){
53 printf("n=%lld\n",n);
54 assert(encontrados);
58 return 0;